package gmomo.test.gui;

import org.jivesoftware.smack.util.StringUtils;

public class Contact {
	
	private String xmppAddress;
	
	public Contact(String xmppAddress) {
		this.xmppAddress = xmppAddress;
	}
	
	public String getXmppAddress() {
		return xmppAddress;
	}
	
	public String getName() {
		return StringUtils.parseName(xmppAddress);
	}
	
	public String getBareAddress() {
		return StringUtils.parseBareAddress(xmppAddress);
	}
	
	public String getServer() {
		return StringUtils.parseServer(xmppAddress);
	}
	
	public String getResource() {
		return StringUtils.parseResource(xmppAddress);
	}
	
	public String toString() {
		return getXmppAddress();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((xmppAddress == null) ? 0 : xmppAddress.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Contact other = (Contact) obj;
		if (xmppAddress == null) {
			if (other.xmppAddress != null)
				return false;
		} else if (!xmppAddress.equals(other.xmppAddress))
			return false;
		return true;
	}
	
}//end of class Contact
